package com.studentSystem.utils;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

//统一响应结果
@NoArgsConstructor
@AllArgsConstructor
@Data
public class ResultUtil<T> {
    private Integer code;//0成功 1失败
    private String message;//用来提示信息
    private T data;//响应数据

    public static <E> ResultUtil<E> success(E data) {
        return new ResultUtil<>(0, "操作成功", data);
    }

    //快速返回操作成功响应结果
    public static ResultUtil success() {
        return new ResultUtil(0, "操作成功", null);
    }

    public static ResultUtil error(String message) {
        return new ResultUtil(1, message, null);
    }
}
